<<<<<<< HEAD
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int i,j,sum=0,t,temp,x;
	int l,num,n,b[100]={};
	int LEN[100]={};
	scanf("%d",&num);
	while(num>0)
	{
		scanf("%d",&n);
		while(n>0)
		{
			
			scanf("%d",&l);
			LEN[l-1]++;
			//printf("%d\n",LEN[l-1]);
			n--;
		}
	for(i=0,j=0;i<100;i++)
		{
			if(LEN[i]!=0){
				b[j]=(LEN[i])/2;
				
				//printf("%d ",b[j]);
				j++;
			}
			
		}
		//printf("\n");
		for(i=0;i<j-1;i++)
		{
			for(t=0;t<(j-1-i);t++)
			{
				if(b[t]<b[t+1])
				{temp=b[t];b[t]=b[t+1];b[t+1]=temp;}
			}
		}
	/*	for(i=0;i<j;i++)
		{
			printf("%d ",b[i]);
		}*/
		for(i=0;i<j-1;i++)
		{
			b[i]=abs(b[i]-b[i+1]);
			if(i==0){sum=b[i+1];continue;}
			sum+=(b[i]<b[i+1]?b[i]:b[i+1]);
		}
		printf("%d\n",sum);
		num--;
	}
	return 0;
=======
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int i,j,sum=0,t,temp,x;
	int l,num,n,b[100]={};
	int LEN[100]={};
	scanf("%d",&num);
	while(num>0)
	{
		scanf("%d",&n);
		while(n>0)
		{
			
			scanf("%d",&l);
			LEN[l-1]++;
			//printf("%d\n",LEN[l-1]);
			n--;
		}
	for(i=0,j=0;i<100;i++)
		{
			if(LEN[i]!=0){
				b[j]=(LEN[i])/2;
				
				//printf("%d ",b[j]);
				j++;
			}
			
		}
		//printf("\n");
		for(i=0;i<j-1;i++)
		{
			for(t=0;t<(j-1-i);t++)
			{
				if(b[t]<b[t+1])
				{temp=b[t];b[t]=b[t+1];b[t+1]=temp;}
			}
		}
	/*	for(i=0;i<j;i++)
		{
			printf("%d ",b[i]);
		}*/
		for(i=0;i<j-1;i++)
		{
			b[i]=abs(b[i]-b[i+1]);
			if(i==0){sum=b[i+1];continue;}
			sum+=(b[i]<b[i+1]?b[i]:b[i+1]);
		}
		printf("%d\n",sum);
		num--;
	}
	return 0;
>>>>>>> 4eb85a45f45791935900b3793d471667a48122f2
}